/**
 * Created by zwq on 2017/6/23
 */
$(function(){
    new descFun();
});

function descFun(){
    this.init();
}
descFun.prototype={
    init:function(){
        this.bind();
        this.pageLoad(); /* 2017/06/23 页面加载完毕前加载动画效果*/

        this.performAnimation(); /* 2017/07/03 动画基本路径执行动画*/

        this.modalCentered();/* 2017/07/27 模态框居中*/

        this.styleSidebarContraction(); /* 2017/06/25 点击顶部按钮时收缩左侧菜单*/

        this.styleSidebarSet(); /* 2017/06/25 左侧菜单的子菜单的点击显示隐藏*/

        this.styleSetNav(); /* 2017/06/25 设置菜单的显示隐藏*/
    },
    bind:function(){
        var slf=this;
    },
    pageLoad:function(){
        $(window).load(function(){
            $(".loading-container").addClass("loading-inactive");
        })
    },
    performAnimation:function(){
        $("a[data-animation]").bind("click",function(){
            var $obj=$(this);
            var $wait=$(this).data("data-animation") || 1300;
            var _attr=$obj.attr("data-animation");

            $obj.removeClass("animated-"+_attr);
            $obj.addClass("animated-"+_attr);
            setTimeout(function(){
                $obj.removeClass("animated-"+_attr);
            },$wait);
        })
    },
    modalCentered:function(){
        $(".modal").on("show.bs.modal",function(){
            var $this=$(this);
            var $modal_dialog=$this.find(".modal-dialog");
            $this.css("dislay","block");
            var _clientHeight=document.documentElement.clientHeight || document.body.clientHeight;
           // $modal_dialog.css({"height":_clientHeight+"px","margin-top":Math.max($(window).height()-$this.height())/2+"px auto"});
        })
    },
    styleSidebarContraction:function(){
        $("#sidebar-collapse").bind("click",function(){
            $("body").toggleClass("sidebar-collapse");
        });
    },
    styleSidebarSet:function(){
        $(".menu-dropdown").bind("click",function(){
            var _par=$(this).parent();
            $(_par).toggleClass("active open").show(300).siblings().removeClass("");
        })
    },
    styleSetNav:function(){
        $(".set-switcher-heading-icon").bind("click",function(){
            $("#setBox").toggleClass("open");
        });
    }
};


/*
*
* 创建日期: 2017/06/23
*    模块：回到顶部
*/
$(document).ready(function(){
    var options={
            _clientHeight:'',
            _scrollTop:''
        };

    $.fn.backTop=function(){
        var _me=$(this);
        window.onscroll=function(){
            options._clientHeight=document.documentElement.clientHeight || document.body.clientHeight;
            options._scrollTop=document.body.scrollTop||document.documentElement.scrollTop;

            if(options._scrollTop>=(options._clientHeight/2)){

                $(_me).fadeIn(500)
                
            }else{

                $(_me).fadeOut(500)
            }
        };
        $(_me).on("click",function(){

            var _ops=$(this);
            $("html").animate({scrollTop:0},500);
            
        });
    };
    $("#backTop").backTop();
});





